package com.yunxi.service.dubboService.impl.vehicle;

import com.github.pagehelper.PageInfo;
import com.yunxi.model.vehicle.VehicleConfigVer;
import com.yunxi.service.localService.vehicle.VehicleConfigVerService;
import com.yunxi.vehicle.pojo.VehicleConfigVO;
import com.yunxi.vehicle.pojo.VehicleConfigVerVO;
import com.yunxi.vehicle.service.VehicleConfigVerDubboService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.cache.annotation.Cacheable;

import java.lang.reflect.InvocationTargetException;
import java.util.List;

/**
 * <p>
 * 工程配置版本明细 服务实现类
 * </p>
 *
 * @author 
 * @since 2019-05-18
 */
/*@com.alibaba.dubbo.config.annotation.Service(version = "${demo.service.version}",
        application = "${dubbo.application.id}",
        protocol = "${dubbo.protocol.id}",
        registry = "${dubbo.registry.id}"
)*/
public class VehicleConfigVerDubboServiceImpl implements VehicleConfigVerDubboService {

    @Autowired
    @Qualifier(value = "vehicleConfigVerServiceImpl")
    VehicleConfigVerService vehicleConfigVerService;


    @Override
    public VehicleConfigVerVO getById(String id) throws InvocationTargetException, IllegalAccessException {
    VehicleConfigVer baseVehicleConfigVer = vehicleConfigVerService.getById(id);
    VehicleConfigVerVO baseVehicleConfigVerVO = new VehicleConfigVerVO();
        BeanUtils.copyProperties(baseVehicleConfigVer,baseVehicleConfigVerVO);
        return baseVehicleConfigVerVO;
    }

    @Override
    public void saveOrUpdate(VehicleConfigVerVO baseVehicleConfigVerVO) throws InvocationTargetException, IllegalAccessException {
    VehicleConfigVer baseVehicleConfigVer = new VehicleConfigVer();
        BeanUtils.copyProperties(baseVehicleConfigVerVO,baseVehicleConfigVer);
    vehicleConfigVerService.saveOrUpdate(baseVehicleConfigVer);
    }

    @Override
    public void removeById(String id) {
    vehicleConfigVerService.removeById(id);
    }

    @Override
    public PageInfo<VehicleConfigVerVO> findPageByVO(VehicleConfigVerVO vehicleConfigVerVO, Integer pageNum, Integer pageSize) throws InvocationTargetException, IllegalAccessException {

      PageInfo<VehicleConfigVerVO> pageInfo = vehicleConfigVerService.pageByVo(vehicleConfigVerVO,pageNum,pageSize);

      return pageInfo;

   }

    @Override
    public List listByVo(VehicleConfigVerVO vo) {
        return vehicleConfigVerService.listByVo(vo);
    }

    @Override
    @Cacheable(value="vehicleConfig",key = "'ver:data_'+#vo.vehicleCode")
    public List<VehicleConfigVO> casList(VehicleConfigVerVO vo) {
        return vehicleConfigVerService.casList(vo);
    }

    @Override
    public List listByColorIn(String vehicleCode) {
        return vehicleConfigVerService.listByColorIn(vehicleCode);
    }

    @Override
    public List listByColorOut(String vehicleCode) {
        return vehicleConfigVerService.listByColorOut(vehicleCode);
    }

    @Override
    public List listByBattary(String vehicleCode) {
        return vehicleConfigVerService.listByBattary(vehicleCode);
    }

    @Override
    public List listByCountry(String vehicleCode) {
        return vehicleConfigVerService.listByCountry(vehicleCode);
    }

    @Override
    public List listByYear(String vehicleCode) {
        return vehicleConfigVerService.listByYear(vehicleCode);
    }

}
